// src/types/Notice.ts
export interface Notice {
  createBy: string
  createTime: string
  updateBy: string | null
  updateTime: string | null
  remark: string
  noticeId: number
  noticeTitle: string
  noticeType: string
  noticeContent: string
  status: string
}

export interface NoticeResponse {
  total: number
  rows: Notice[]
  code: number
  msg: string
}

// import { NoticeResponse } from '../types/Notice';
import axios from 'axios'
//通过从 stores 获取 token
import useUserStore from '@/stores/index'
const store = useUserStore()  // 假设你有一个 stores/index.ts 文件并且在这里定义了 storeconst
const API_URL = 'http://119.29.41.94:8080/system/notice/list'


export const getNotices = async (): Promise<NoticeResponse> => {
 // 获取 store 实例
  console.log(store.$state.token)

  //  const token = store.token; // 假设你的 token 存储在 store.token // 设置请求头
  const response = await axios.get<NoticeResponse>(API_URL, {
    headers: {
      Authorization: `Bearer ${store.$state.token}` // 添加 Bearer token 到请求头
    }
  })
  return response.data
}
